$input a_texcoord0, a_position
#ifdef INSTANCING
  $input i_data0, i_data1, i_data2, i_data3
#endif
$output texcolor, worldpos, v_texcoord0

#include <bgfx_shader.sh>
#include <Fuctions_MLYX.glsl>

uniform vec4 FogAndDistanceControl;
uniform vec4 ViewPositionAndTime;
uniform vec4 FogColor;

void main() {

#ifdef INSTANCING
  mat4 model = mtxFromCols(i_data0, i_data1, i_data2, i_data3);
#else
  mat4 model = u_model[0];
#endif

  vec3 pos = mul(model, vec4(a_position, 1.0)).xyz;

  texcolor = vec3(1.0,0.0,0.0);
  v_texcoord0 = 2.0*a_texcoord0;
  worldpos = pos;
  gl_Position = mul(u_viewProj, vec4(pos, 1.0));
}